#!/bin/bash
##生成docker的配置文件daemon.json
main(){
    
    if [ -f /etc/docker/daemon.json ];then
        echo "已存在daemon.json"
        return 1
    fi
    sudo sh -c 'mkdir -p /etc/docker && cat >/etc/docker/daemon.json  <<EOF
{
  "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com/",
    "https://harbor.inglod.net"
  ],
  "insecure-registries": ["harbor.echronos.com"],
  "log-driver": "json-file",
  "log-opts": {"max-size":"50m", "max-file":"3"},
   "data-root": "/data/docker_storage",
  "exec-opts": ["native.cgroupdriver=cgroupfs"],
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
                 
EOF'
    cat /etc/docker/daemon.json

}
main